#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>

#include <QFontDatabase>
#include <iostream>
#include <QThread>
#include <memory>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <QApplication>

#include "widget.h"


int main(int argc, char *argv[])
{
    //QGuiApplication app(argc, argv);
    QApplication app(argc, argv);

    qSetMessagePattern("[HMI]%{file}(%{line}): %{message}");
    QQmlApplicationEngine engine;

    Widget w;
    engine.rootContext()->setContextProperty("obj", &w);

    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                     &app, [url](QObject *obj, const QUrl &objUrl) {
        if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
    }, Qt::QueuedConnection);
    engine.load(url);

    QList<QObject*> list = engine.rootObjects();
    QObject *obj = list.first();
    if(obj)
    {

        w.show();
        w.setObject(obj);

        return app.exec();
    }

}
